package com.moleq.models;

import com.moleq.db.DatabaseSchema;

import android.R.integer;

public class MultCouponSetting {
//	CREATE TABLE t_mult_cpn_setting
//	(mc_id INTEGER NOT NULL,
//	mc_active varchar(1) DEFAULT '0' NOT NULL,
//	mc_cpn_name varchar(30) NULL,
//	mc_mult integer DEFAULT 2 NOT NULL,
//	mc_add_value numeric(8,3) NULL,
//	mc_max_value numeric(8,3) NULL,
//	mc_max_total numeric(8,3) NULL,
//	create_datetime varchar(14) NULL,
//	update_datetime varchar(14) NULL,
//	PRIMARY KEY (mc_id));
	
	private String mc_id = null;
	private String mc_active;
	private String mc_cpn_name;
	private int mc_mult;
	private Double mc_add_value;
	private Double mc_max_value;
	private Double mc_max_total;
	private String create_datetime;
	private String update_datetime;
	
	public MultCouponSetting(){}
	public MultCouponSetting(String mc_id,String mc_active,String mc_cpn_name,int mc_mult,Double mc_add_value,Double mc_max_value,
			Double mc_max_total,String create_datetime,String update_datetime){
		this.mc_id = mc_id;
		this.mc_active = mc_active;
		this.mc_cpn_name = mc_cpn_name;
		this.mc_mult = mc_mult;
		this.mc_add_value = mc_add_value;
		this.mc_max_value = mc_max_value;
		this.mc_max_total = mc_max_total;
		this.create_datetime = create_datetime;
		this.update_datetime = update_datetime;
	}
	
	public MultCouponSetting(String mc_id,String mc_active,String mc_cpn_name,int mc_mult,Double mc_add_value,Double mc_max_value,
			Double mc_max_total){
		this.mc_id = mc_id;
		this.mc_active = mc_active;
		this.mc_cpn_name = mc_cpn_name;
		this.mc_mult = mc_mult;
		this.mc_add_value = mc_add_value;
		this.mc_max_value = mc_max_value;
		this.mc_max_total = mc_max_total;
	}
	
	public String getMc_id() {
		return mc_id;
	}
	public void setMc_id(String mc_id) {
		this.mc_id = mc_id;
	}
	public String getMc_active() {
		return mc_active;
	}
	public void setMc_active(String mc_active) {
		this.mc_active = mc_active;
	}
	public boolean getMc_activeCheckBox(){
		if(mc_active.equals("0")){
			return false;
		}else{
			return true;
		}
	}
	public void setMc_active(boolean mc_active){
		if(mc_active){
			this.mc_active = "1";
		}else{
			this.mc_active = "0";
		}
	}
	public String getMc_cpn_name() {
		return mc_cpn_name;
	}
	public void setMc_cpn_name(String mc_cpn_name) {
		this.mc_cpn_name = mc_cpn_name;
	}
	public int getMc_mult() {
		return mc_mult;
	}
	public void setMc_mult(int mc_mult) {
		this.mc_mult = mc_mult;
	}
	public Double getMc_add_value() {
		return mc_add_value;
	}
	public void setMc_add_value(Double mc_add_value) {
		this.mc_add_value = mc_add_value;
	}
	public Double getMc_max_value() {
		return mc_max_value;
	}
	public void setMc_max_value(Double mc_max_value) {
		this.mc_max_value = mc_max_value;
	}
	public Double getMc_max_total() {
		return mc_max_total;
	}
	public void setMc_max_total(Double mc_max_total) {
		this.mc_max_total = mc_max_total;
	}
	public String getCreate_datetime() {
		return create_datetime;
	}
	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}
	public String getUpdate_datetime() {
		return update_datetime;
	}
	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}
//	CREATE TABLE t_mult_cpn_setting
//	(mc_id INTEGER NOT NULL,
//	mc_active varchar(1) DEFAULT '0' NOT NULL,
//	mc_cpn_name varchar(30) NULL,
//	mc_mult integer DEFAULT 2 NOT NULL,
//	mc_add_value numeric(8,3) NULL,
//	mc_max_value numeric(8,3) NULL,
//	mc_max_total numeric(8,3) NULL,
//	create_datetime varchar(14) NULL,
//	update_datetime varchar(14) NULL,
//	PRIMARY KEY (mc_id));
	public String toMGData(String Action) {
		String Result = Action + "|" + DatabaseSchema.MultCouponSetting.SCHEMA_NAME
				+ "|(" + CheckNull(getMc_id()) + "," + CheckNull(getMc_active()) + "," + CheckSign(getMc_cpn_name()) + "," +
				getMc_mult() + "," + getMc_add_value() + "," + getMc_max_value() + "," + getMc_max_total() + "," + 
				CheckNull(getCreate_datetime()) + "," + CheckNull(getUpdate_datetime()) + ")";
		return Result;
	}
	
	public String CheckNull(String value) {
		if (value == null) {
			return null;
		} else {
			return "'" + value + "'";
		}
	}
	
	public String CheckSign(String str){
		if(str == null) return null;
		String data = str.substring(1, (str.length() - 1));
		String result = "";
		for (int i = 0; i < data.length(); i++) {
			String charString = String.valueOf(data.charAt(i));
			if(charString.equals("'")){
				result += charString + "'";
			}else{
				result += charString;
			}
		}
		
		return "'" + result + "'";
	}
}
